<?php include(TEMPLATE_DIR . 'header.tpl'); ?>
<?php include(TEMPLATE_DIR . 'nav.tpl'); ?>
<div class="main">
	<div class="push_stat_title">
		<h2>Push主机<!--<?php echo (isset($output['date_label']) && strlen($output['date_label'])) ? '[<span style="color:#35AAE5;">' . $output['date_label'] . '</span>]' : ''; ?>--><?php echo (isset($output['date_label']) && strlen($output['date_label'])) ? $output['date_label'] : ''; ?>实时数据</h2>
		<div class="line"></div>
	</div>
	<?php include($this->getVar('template_path') . 'search_box.tpl'); ?>
	<div class="push_stat_table_box">
		<table class="push_stat_host_table" border="0" cellpadding="0" width="100%">
			<tr>
				<?php if ($query['show_type'] === 'date'): ?>
					<th>日期/时间</th>
					<th>主机</th>
				<?php else: ?>
					<th>主机</th>
					<th>日期/时间</th>
				<?php endif; ?>
				<th>成功数量</th>
				<th>花费时间(成功)</th>
				<th>失败数量</th>
				<th>花费时间(失败)</th>
			</tr>
			<!-- 总计行 start -->
			<?php if(isset($output['data']['total']) && !empty($output['data']['total'])): ?>
				<tr class="all">
					<td><span>总计/均值</span></td>
					<td><?php echo $this->format(null); ?></td>
					<td class="success_num"><?php echo $output['data']['total']['count_success']; ?></td>
					<td>
						<?php if (!is_null($output['data']['total']['avg_spend_time_success'])) : ?>
							<span class="second" title="<?php echo $this->format($output['data']['total']['avg_spend_time_success'], 'STD_FLOAT_TIME_FULL'); ?>">
								<?php echo $this->format($output['data']['total']['avg_spend_time_success'], 'STD_FLOAT_TIME'); ?>
							</span>
						<?php else: ?>
							<?php echo $this->format(null); ?>
						<?php endif; ?>
					</td>
					<td class="fail_num"><?php echo $output['data']['total']['count_fail']; ?></td>
					<td>
						<?php if (!is_null($output['data']['total']['avg_spend_time_fail'])) : ?>
							<span class="second" title="<?php echo $this->format($output['data']['total']['avg_spend_time_fail'], 'STD_FLOAT_TIME_FULL'); ?>">
								<?php echo $this->format($output['data']['total']['avg_spend_time_fail'], 'STD_FLOAT_TIME'); ?>
							</span>
						<?php else: ?>
							<?php echo $this->format(null); ?>
						<?php endif; ?>
					</td>
				</tr>		
			<?php endif; ?>
			<!-- 总计行 end -->
			<?php if(!empty($output['data']['list'])): ?>
				<?php foreach ($output['data']['list'] as $row): ?>
					<tr>
					<?php $mainCol = ($query['show_type'] === 'date' ? 'stat_col' : 'hoststr'); ?>
					<?php $groupKey = strval($row[$mainCol]); ?>
					<?php if($query['show_type'] === 'date'): ?>
						<?php if($output['data']['count'][$groupKey] > 1): ?>
							<td rowspan="<?php echo $output['data']['count'][$groupKey]; ?>"><?php echo $this->format($row['stat_col'], 'HOUR_TEXT'); ?></td>

							<?php $output['data']['count'][$groupKey] = false; ?>
						<?php else: ?>
							<?php if ($output['data']['count'][$groupKey] !== false): ?>
								<td><?php echo $this->format($row['stat_col'], 'HOUR_TEXT'); ?></td>
							<?php endif; ?>
						<?php endif; ?>
						<td><?php echo $this->format($row['hoststr'], null, '未知'); ?></td>
					<?php else: ?>
						<?php if($output['data']['count'][$groupKey] > 1): ?>
							<td rowspan="<?php echo $output['data']['count'][$groupKey]; ?>"><?php echo $this->format($row['hoststr'], null, '未知'); ?></td>
							<?php $output['data']['count'][$groupKey] = false; ?>
						<?php else: ?>
							<?php if ($output['data']['count'][$groupKey] !== false): ?>
								<td><?php echo $this->format($row['hoststr'], null, '未知'); ?></td>
							<?php endif; ?>
						<?php endif; ?>
						<td><?php echo $this->format($row['stat_col'], 'HOUR_TEXT'); ?></td>
					<?php endif; ?>
						<td>
							<span class="stat-success">
								<?php echo (int)$row['count_success']; ?>
							</span>
						</td>
						<td>
							<?php if (!is_null($row['avg_spend_time_success'])) : ?>
								<span class="second" title="<?php echo $this->format($row['avg_spend_time_success'], 'STD_FLOAT_TIME_FULL'); ?>"><?php echo $this->format($row['avg_spend_time_success'], 'STD_FLOAT_TIME'); ?></span>
							<?php else: ?>
								<?php echo $this->format(null); ?>
							<?php endif; ?>
						</td>
						<td>
							<span class="stat-fail">
								<?php echo (int)$row['count_fail']; ?>
							</span>
						</td>
						<td>
							<?php if (!is_null($row['avg_spend_time_fail'])) : ?>
								<span class="second" title="<?php echo $this->format($row['avg_spend_time_fail'], 'STD_FLOAT_TIME_FULL'); ?>"><?php echo $this->format($row['avg_spend_time_fail'], 'STD_FLOAT_TIME'); ?></span>
							<?php else: ?>
								<?php echo $this->format(null); ?>
							<?php endif; ?>
						</td>
					</tr>	
				<?php endforeach; ?>
			<?php else: ?>
				<tr><td colspan="6"></td></tr>
			<?php endif; ?>
		</table>
		<div class="push_stat_tips">
			注:默认显示当天，全部主机的统计数据.
		</div>
	</div>
</div>
<script type="text/javascript">
$(function(){
	// 加载表单初始设置
	pstat.loadForm('stat_search_form');
});
</script>
<?php include(TEMPLATE_DIR . 'footer.tpl'); ?>
